/*     */ package com.newcrm.db;
/*     */ 
/*     */ import com.newcrm.exception.DBException;
/*     */ import java.sql.Connection;
/*     */ import java.sql.SQLException;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.dbutils.DbUtils;
/*     */ import org.apache.commons.dbutils.MyMapListHandler;
/*     */ import org.apache.commons.dbutils.QueryRunner;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class SMSMessageManager
/*     */ {
/*  18 */   private static Logger logger = Logger.getLogger(SMSMessageManager.class
/*  19 */     .getName());
/*     */ 
/*     */   public int add(String mobiles, String msg, int customerId, int parentCustomerId, String sendUserId)
/*     */     throws DBException
/*     */   {
/*  34 */     if ((mobiles == null) || (mobiles.trim().length() == 0)) {
/*  35 */       return 0;
/*     */     }
/*     */ 
/*  38 */     if ((msg == null) || (msg.trim().length() == 0)) {
/*  39 */       return 0;
/*     */     }
/*  41 */     if (customerId <= 0) {
/*  42 */       return 0;
/*     */     }
/*     */ 
/*  45 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  46 */     if (conn == null) {
/*  47 */       throw new DBException();
/*     */     }
/*  49 */     QueryRunner runner = new QueryRunner();
/*     */     try {
/*  51 */       return runner.update(conn, "INSERT INTO T_Company_SMS_Msg_Info (mobiles,msg,CustomerId,ParentCustomerId,SendUserId,CreateDate) VALUES (?,?,?,?,?,NOW())", new Object[] { mobiles, msg, 
/*  52 */         Integer.valueOf(customerId), Integer.valueOf(parentCustomerId), sendUserId });
/*     */     } catch (SQLException e) {
/*  54 */       e.printStackTrace();
/*  55 */       logger.warn("add sms message failed", e);
/*     */     } finally {
/*     */       try {
/*  58 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  60 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*  63 */     return 0;
/*     */   }
/*     */ 
/*     */   public List<Map<String, Object>> getPeopleSMSMsg(int customerId)
/*     */     throws DBException, SQLException
/*     */   {
/*  76 */     Connection conn = ConnectionManager.getInstance().getConnection();
/*  77 */     if (conn == null) {
/*  78 */       return null;
/*     */     }
/*  80 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/*  83 */       return (List)runner.query(conn, "SELECT * FROM T_Company_SMS_Msg_Info WHERE CustomerId = ? ORDER BY CreateDate DESC", 
/*  84 */         new MyMapListHandler(), new Object[] { Integer.valueOf(customerId) });
/*     */     }
/*     */     finally {
/*     */       try {
/*  88 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/*  90 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ 
/*     */   public List<Map<String, Object>> getCompanySMSMsg(int parentCustomerId)
/*     */     throws DBException, SQLException
/*     */   {
/* 105 */     Connection conn = ConnectionManager.getInstance().getConnection();
/* 106 */     if (conn == null) {
/* 107 */       return null;
/*     */     }
/* 109 */     QueryRunner runner = new QueryRunner();
/*     */     try
/*     */     {
/* 112 */       return (List)runner.query(conn, "SELECT * FROM T_Company_SMS_Msg_Info WHERE ParentCustomerId = ? ORDER BY CreateDate DESC", 
/* 113 */         new MyMapListHandler(), new Object[] { Integer.valueOf(parentCustomerId) });
/*     */     }
/*     */     finally {
/*     */       try {
/* 117 */         DbUtils.close(conn);
/*     */       } catch (SQLException e) {
/* 119 */         logger.warn("close conn failed", e);
/*     */       }
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.db.SMSMessageManager
 * JD-Core Version:    0.6.1
 */